import 'package:flutter/cupertino.dart';
import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';


class ChewiePlayerPage extends StatefulWidget {
  // const ChewiePlayerPage({Key? key}) : super(key: key);

  var urlStr;

  ChewiePlayerPage(this.urlStr);

  @override
  _ChewiePlayerPageState createState() => _ChewiePlayerPageState();
}

class _ChewiePlayerPageState extends State<ChewiePlayerPage> {



  VideoPlayerController? videoPlayerController;
  ChewieController? chewieController;
  @override
  void initState() {
    // TODO: implement initState

     videoPlayerController = VideoPlayerController.network(
        '${widget.urlStr}');

     chewieController = ChewieController(

      videoPlayerController: videoPlayerController!,
      autoPlay: false,
      looping: false,
       aspectRatio: 2/1,

       // showControls: false,
       materialProgressColors: ChewieProgressColors(
         playedColor: Colors.red,
         handleColor: Colors.blue,
         backgroundColor: Colors.grey,
         bufferedColor: Colors.lightGreen,
       ),
       placeholder: Container(
         color: Colors.white,
       ),
       autoInitialize: true,
    );

    super.initState();
  }

  @override
  void dispose() {
    videoPlayerController!.dispose();
    chewieController!.dispose();
    super.dispose();
  }


  @override
  Widget build(BuildContext context) {
    final playerWidget = Chewie(
      controller: chewieController!,
    );
    return Scaffold(
      body: playerWidget,
    );
  }
}
